package main

import (
	"fmt"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/middleware/recover"
	"github.com/kataras/iris/v12/mvc"
	"github.com/rs/cors"
	"gowork/hotelOrder/controller"
	"gowork/hotelOrder/utils"
)

func main()  {
	w := new(utils.Worker)
	for i:=1; i<=15; i++ {
		fmt.Println(w.GetId())
	}

	app := iris.New()

	//app.Use(recover.New())
	//// 所有请求前面添加拦截器
	//app.Use(medium.Cors)
	//common := app.Party("/")
	//{
	//	common.Options("*", func(ctx iris.Context) {
	//		ctx.Next()
	//	})
	//}

	// 解决跨域的主要代码
	c := cors.New(cors.Options{
		AllowedOrigins:   []string{"*"},
		AllowCredentials: true,
		Debug:            true,
	})
	app.WrapRouter(c.ServeHTTP)
	app.Use(recover.New())

	mvc.New(app).Handle(new(controller.HotelController))

	fmt.Println("启动。。。。。。。")
	app.Run(iris.Addr(":5394"))
}
